#include "startwindow.h"
#include "ui_startwindow.h"

#include<QPushButton>
#include"widget.h"
#include<QPalette>


StartWindow::StartWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::StartWindow)
{
    ui->setupUi(this);
    QPushButton *spb=new QPushButton("Startgame",this);
    spb->move(50,200);

    QPalette palette; // 创建一个QPalette对象
    // 设置背景图片
    QPixmap background("://map/start.jpg");
    background = background.scaled(this->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    palette.setBrush(QPalette::Window, QBrush(background));

    // 将palette应用于当前窗口
    this->setPalette(palette);

    // 将palette应用于当前窗口
    this->setPalette(palette);
    connect(spb, &QPushButton::clicked, this, &StartWindow::startGame);
}
void StartWindow::startGame()
{
    emit startGameSignal(); // 发送游戏开始信号
    close();//关闭初始界面
}
void StartWindow::onGameFinished()
{
    // 断开信号和槽的连接
    disconnect(this, &StartWindow::startGameSignal, nullptr, nullptr);
}

StartWindow::~StartWindow()
{
    delete ui;
}
